package com.jiangyg.mall.coupon.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.coupon.dao.CouponSpuCategoryDao;
import com.jiangyg.mall.coupon.dto.CouponSpuCategoryDTO;
import com.jiangyg.mall.coupon.entity.CouponSpuCategory;
import com.jiangyg.mall.coupon.vo.CouponSpuCategoryVO;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CouponSpuCategoryServiceImpl extends BaseServiceImpl<CouponSpuCategoryDao, CouponSpuCategory> implements CouponSpuCategoryService {

    @Autowired
    public CouponSpuCategoryServiceImpl(CouponSpuCategoryDao couponSpuCategoryDao) {
        super(couponSpuCategoryDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<CouponSpuCategoryVO> selectPagination(Pagination<CouponSpuCategoryVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, CouponSpuCategoryVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(CouponSpuCategoryDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public CouponSpuCategoryVO selectById(Long couponSpuCategoryId) throws Exception {
        return this.executeSelectById(couponSpuCategoryId, CouponSpuCategoryVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> couponSpuCategoryIds) {
        return this.baseMapper.deleteBatchIds(couponSpuCategoryIds) > 0;
    }

}
